<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      if (age < 0) {
        // console.log("age 错误");
        // console.log("age error");
        // console.log("age ！！");
        throw new AgeError("年龄错误");
      }
      class AgeError extends Error {
        name = "AgeError";
      }
      class PhoneError extends Error {
        name = "PhoneError";
      }
      class EmailError extends Error {
        name = "EmailError";
      }
      try {
        throw new AgeError("年龄错误");
        // throw new PhoneError("手机格式错误");
        // throw new EmailError("邮箱错误");
      } catch (error) {
        console.log(error.name);
        console.log(error.message);
      }
    </script>
  </body>
</html>
